<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Proxy的使用</title>
</head>
<body>
    
</body>
</html>

<script>
    // 用于代理对象，与 Object.defineProperty() 联系起来
    let obj = {
        username: 'cellophane',
        job: 'fontEndEnginner'
    }

    const p1 = new Proxy(obj, {
        get(target, prop, sl) {
            console.log('sl:', sl)
            return target[prop]
        },
        set(target, prop, value) {
            target[prop] = value
        }
    })
    p1.username = '周钰'
    console.log('p1.username:', p1.username)
</script>